<%@page import="multiface.web.util.Define"%>
<%@page import="java.util.LinkedList"%>
<%@page import="java.util.List"%>
<%@page import="multiface.web.util.Util"%>
<%@page import="multiface.promonet.jpa.Lavoro"%>
<%@page import="multiface.promonet.jpa.Utente"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page import="multiface.promonet.jpa.util.PersistenceManager"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%
    EntityManagerFactory emf = PersistenceManager.getInstance().getEntityManagerFactory();
    EntityManager em = emf.createEntityManager();

    Utente p = (Utente) session.getAttribute(Define.USER_SESSION);

    em.close();
%>

<script>
    var tagsel=null;
    function swap(tag){
        $("#div-"+tag).hide();
        $("#input-"+tag).show();
        $("#input2-"+tag).show();
        tagsel=tag;
    }   
    function over(tag){
        if(tagsel==null){
            $("#img-"+tag).show();
        }
    }
    function out(tag){
        $("#img-"+tag).hide();
    }
    function save(){
        $("#form-edit").hide();
        $("#saving").show();
        
        $.post('ActionServlet',{
            utenteid : <%=p.getIdutente()%>,
            name : $("#name").val(),
            surname : $("#surname").val(),
            email : $("#email").val(),
            password : $("#password").val(),
            action:'mod_login',
            section: 'account'
        },function (data){
            $("#form-edit").show();
            $("#saving").hide();
        });
    }
</script>
<style>
    .inputs{
        float: left;
        padding: 2px;
        margin-right: 2px;
    }
    .save{
        font-weight: bold;
    }
    .save:hover{
        font-weight: bold; 
        background-color: #c1ffd5;
    }
    .td-left{
        width: 120px;
        font-size: 14px; 
        color: #2281CF
    }
</style>

<div id="center">
        <div class="center-title">Informazioni di Accesso al Sistema</div>
    <div id="saving" style="display: none; padding: 20px;">
        <div><img src="engine/img/loading3.gif"/> </div>
        <div>Salvataggio in Corso...</div>
    </div>

    <form id="form-edit" action="javascript:save();" accept-charset="UTF-8">
        <table class="center-table-edit">
            <tr>
                <td class="td-left">Nome</td>
                <td>
                    <input  id="name" class="inputs" type="text" value="<%=p.getNome()%>">
                </td>
            </tr>
            <tr>
                <td class="td-left">Cognome</td>
                <td>
                    <input  id="surname" class="inputs" type="text" value="<%=p.getCognome()%>">
                </td>
            </tr>
            <tr>
                <td class="td-left">E-Mail</td>
                <td>
                    <input  id="email" size="60" class="inputs" type="text" value="<%=p.getEmail()%>">
                </td>
            </tr>
            <tr>
                <td class="td-left">Password</td>
                <td>
                    <input id="password" size="60" class="inputs" type="text" value="<%=p.getPassword()%>">
                </td>
            </tr>
            <tr>
                <td class="td-left"></td>
                <td>
                    <input id="save" size="60" class="inputs save" type="submit" value="SALVA">
                </td>
            </tr>
        </table>
    </form>
</div>